package b.b.c;

import android.content.Context;
import android.content.DialogInterface;
import android.content.DialogInterface.OnClickListener;
import android.content.DialogInterface.OnKeyListener;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.os.Bundle;
import android.text.TextUtils;
import android.util.TypedValue;
import android.view.ContextThemeWrapper;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewGroup.LayoutParams;
import android.widget.Button;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.ListAdapter;
import android.widget.ListView;
import android.widget.TextView;
import androidx.appcompat.app.AlertController;
import androidx.appcompat.app.AlertController.RecycleListView;
import androidx.appcompat.app.AlertController.b;
import androidx.appcompat.app.AlertController.d;
import androidx.appcompat.widget.LinearLayoutCompat;
import androidx.core.widget.NestedScrollView;
import b.i.k.o;
import com.pgl.sys.ces.out.ISdkLite;
import java.util.Objects;
import java.util.WeakHashMap;

/* compiled from: AlertDialog */
public class f extends m implements DialogInterface {
    public final AlertController c = new AlertController(getContext(), this, getWindow());

    /* compiled from: AlertDialog */
    public static class a {
        public final b a;
        public final int b;

        public a(Context context) {
            int d = f.d(context, 0);
            this.a = new b(new ContextThemeWrapper(context, f.d(context, d)));
            this.b = d;
        }

        public f a() {
            CharSequence charSequence;
            TextView textView;
            f fVar = new f(this.a.a, this.b);
            b bVar = this.a;
            AlertController alertController = fVar.c;
            View view = bVar.e;
            if (view != null) {
                alertController.G = view;
            } else {
                charSequence = bVar.d;
                if (charSequence != null) {
                    alertController.e = charSequence;
                    textView = alertController.E;
                    if (textView != null) {
                        textView.setText(charSequence);
                    }
                }
                Drawable drawable = bVar.c;
                if (drawable != null) {
                    alertController.C = drawable;
                    alertController.B = 0;
                    ImageView imageView = alertController.D;
                    if (imageView != null) {
                        imageView.setVisibility(0);
                        alertController.D.setImageDrawable(drawable);
                    }
                }
            }
            charSequence = bVar.f;
            if (charSequence != null) {
                alertController.f = charSequence;
                textView = alertController.F;
                if (textView != null) {
                    textView.setText(charSequence);
                }
            }
            CharSequence charSequence2 = bVar.g;
            if (charSequence2 != null) {
                alertController.e(-1, charSequence2, bVar.h, null, null);
            }
            charSequence2 = bVar.i;
            if (charSequence2 != null) {
                alertController.e(-2, charSequence2, bVar.j, null, null);
            }
            charSequence2 = bVar.k;
            if (charSequence2 != null) {
                alertController.e(-3, charSequence2, bVar.l, null, null);
            }
            if (!(bVar.p == null && bVar.q == null)) {
                int i;
                RecycleListView recycleListView = (RecycleListView) bVar.b.inflate(alertController.L, null);
                if (bVar.u) {
                    i = alertController.N;
                } else {
                    i = alertController.O;
                }
                ListAdapter listAdapter = bVar.q;
                if (listAdapter == null) {
                    listAdapter = new d(bVar.a, i, 16908308, bVar.p);
                }
                alertController.H = listAdapter;
                alertController.I = bVar.v;
                if (bVar.r != null) {
                    recycleListView.setOnItemClickListener(new e(bVar, alertController));
                }
                if (bVar.u) {
                    recycleListView.setChoiceMode(1);
                }
                alertController.g = recycleListView;
            }
            view = bVar.t;
            if (view != null) {
                alertController.h = view;
                alertController.i = 0;
                alertController.n = false;
            } else {
                int i2 = bVar.s;
                if (i2 != 0) {
                    alertController.h = null;
                    alertController.i = i2;
                    alertController.n = false;
                }
            }
            fVar.setCancelable(this.a.m);
            if (this.a.m) {
                fVar.setCanceledOnTouchOutside(true);
            }
            Objects.requireNonNull(this.a);
            fVar.setOnCancelListener(null);
            fVar.setOnDismissListener(this.a.n);
            OnKeyListener onKeyListener = this.a.o;
            if (onKeyListener != null) {
                fVar.setOnKeyListener(onKeyListener);
            }
            return fVar;
        }

        public a b(int i, OnClickListener onClickListener) {
            b bVar = this.a;
            bVar.i = bVar.a.getText(i);
            this.a.j = onClickListener;
            return this;
        }

        public a c(int i, OnClickListener onClickListener) {
            b bVar = this.a;
            bVar.k = bVar.a.getText(i);
            this.a.l = null;
            return this;
        }

        public a d(int i, OnClickListener onClickListener) {
            b bVar = this.a;
            bVar.g = bVar.a.getText(i);
            this.a.h = onClickListener;
            return this;
        }

        public a e(int i) {
            b bVar = this.a;
            bVar.d = bVar.a.getText(i);
            return this;
        }

        public a f(int i) {
            b bVar = this.a;
            bVar.t = null;
            bVar.s = i;
            return this;
        }

        public f g() {
            f a = a();
            a.show();
            return a;
        }
    }

    public f(Context context, int i) {
        super(context, d(context, i));
    }

    public static int d(Context context, int i) {
        if (((i >>> 24) & ISdkLite.REGION_UNSET) >= 1) {
            return i;
        }
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(2130968614, typedValue, true);
        return typedValue.resourceId;
    }

    public Button c(int i) {
        AlertController alertController = this.c;
        Objects.requireNonNull(alertController);
        if (i == -3) {
            return alertController.w;
        }
        if (i == -2) {
            return alertController.s;
        }
        if (i != -1) {
            return null;
        }
        return alertController.o;
    }

    public void onCreate(Bundle bundle) {
        int i;
        int indexOfChild;
        int i2;
        Drawable drawable;
        Drawable drawable2;
        int i3;
        Drawable drawable3;
        ListView listView;
        super.onCreate(bundle);
        AlertController alertController = this.c;
        if (alertController.K == 0) {
            i = alertController.J;
        } else {
            i = alertController.J;
        }
        alertController.b.setContentView(i);
        View findViewById = alertController.c.findViewById(2131296782);
        View findViewById2 = findViewById.findViewById(2131297063);
        View findViewById3 = findViewById.findViewById(2131296477);
        View findViewById4 = findViewById.findViewById(2131296414);
        ViewGroup viewGroup = (ViewGroup) findViewById.findViewById(2131296488);
        View view = alertController.h;
        int i4 = 0;
        if (view == null) {
            view = alertController.i != 0 ? LayoutInflater.from(alertController.a).inflate(alertController.i, viewGroup, false) : null;
        }
        Object obj = view != null ? 1 : null;
        if (obj == null || !AlertController.a(view)) {
            alertController.c.setFlags(131072, 131072);
        }
        if (obj != null) {
            FrameLayout frameLayout = (FrameLayout) alertController.c.findViewById(2131296487);
            frameLayout.addView(view, new LayoutParams(-1, -1));
            if (alertController.n) {
                frameLayout.setPadding(alertController.j, alertController.k, alertController.l, alertController.m);
            }
            if (alertController.g != null) {
                ((LinearLayoutCompat.LayoutParams) viewGroup.getLayoutParams()).a = 0.0f;
            }
        } else {
            viewGroup.setVisibility(8);
        }
        View findViewById5 = viewGroup.findViewById(2131297063);
        View findViewById6 = viewGroup.findViewById(2131296477);
        View findViewById7 = viewGroup.findViewById(2131296414);
        ViewGroup d = alertController.d(findViewById5, findViewById2);
        ViewGroup d2 = alertController.d(findViewById6, findViewById3);
        ViewGroup d3 = alertController.d(findViewById7, findViewById4);
        NestedScrollView nestedScrollView = (NestedScrollView) alertController.c.findViewById(2131296863);
        alertController.A = nestedScrollView;
        nestedScrollView.setFocusable(false);
        alertController.A.setNestedScrollingEnabled(false);
        TextView textView = (TextView) d2.findViewById(16908299);
        alertController.F = textView;
        if (textView != null) {
            CharSequence charSequence = alertController.f;
            if (charSequence != null) {
                textView.setText(charSequence);
            } else {
                textView.setVisibility(8);
                alertController.A.removeView(alertController.F);
                if (alertController.g != null) {
                    ViewGroup viewGroup2 = (ViewGroup) alertController.A.getParent();
                    indexOfChild = viewGroup2.indexOfChild(alertController.A);
                    viewGroup2.removeViewAt(indexOfChild);
                    viewGroup2.addView(alertController.g, indexOfChild, new LayoutParams(-1, -1));
                } else {
                    d2.setVisibility(8);
                }
            }
        }
        Button button = (Button) d3.findViewById(16908313);
        alertController.o = button;
        button.setOnClickListener(alertController.R);
        if (TextUtils.isEmpty(alertController.p) && alertController.r == null) {
            alertController.o.setVisibility(8);
            i2 = 0;
        } else {
            alertController.o.setText(alertController.p);
            drawable = alertController.r;
            if (drawable != null) {
                indexOfChild = alertController.d;
                drawable.setBounds(0, 0, indexOfChild, indexOfChild);
                alertController.o.setCompoundDrawables(alertController.r, null, null, null);
            }
            alertController.o.setVisibility(0);
            i2 = 1;
        }
        Button button2 = (Button) d3.findViewById(16908314);
        alertController.s = button2;
        button2.setOnClickListener(alertController.R);
        if (TextUtils.isEmpty(alertController.t) && alertController.v == null) {
            alertController.s.setVisibility(8);
        } else {
            alertController.s.setText(alertController.t);
            drawable2 = alertController.v;
            if (drawable2 != null) {
                i3 = alertController.d;
                drawable2.setBounds(0, 0, i3, i3);
                alertController.s.setCompoundDrawables(alertController.v, null, null, null);
            }
            alertController.s.setVisibility(0);
            i2 |= 2;
        }
        button2 = (Button) d3.findViewById(16908315);
        alertController.w = button2;
        button2.setOnClickListener(alertController.R);
        if (TextUtils.isEmpty(alertController.x) && alertController.z == null) {
            alertController.w.setVisibility(8);
            drawable3 = null;
        } else {
            alertController.w.setText(alertController.x);
            drawable2 = alertController.z;
            if (drawable2 != null) {
                i3 = alertController.d;
                drawable2.setBounds(0, 0, i3, i3);
                drawable3 = null;
                alertController.w.setCompoundDrawables(alertController.z, null, null, null);
            } else {
                drawable3 = null;
            }
            alertController.w.setVisibility(0);
            i2 |= 4;
        }
        Context context = alertController.a;
        TypedValue typedValue = new TypedValue();
        context.getTheme().resolveAttribute(2130968612, typedValue, true);
        if ((typedValue.data != 0 ? 1 : null) != null) {
            if (i2 == 1) {
                alertController.b(alertController.o);
            } else if (i2 == 2) {
                alertController.b(alertController.s);
            } else if (i2 == 4) {
                alertController.b(alertController.w);
            }
        }
        if ((i2 != 0 ? 1 : null) == null) {
            d3.setVisibility(8);
        }
        if (alertController.G != null) {
            d.addView(alertController.G, 0, new LayoutParams(-1, -2));
            alertController.c.findViewById(2131297057).setVisibility(8);
        } else {
            alertController.D = (ImageView) alertController.c.findViewById(16908294);
            if ((TextUtils.isEmpty(alertController.e) ^ 1) == 0 || !alertController.P) {
                alertController.c.findViewById(2131297057).setVisibility(8);
                alertController.D.setVisibility(8);
                d.setVisibility(8);
            } else {
                textView = (TextView) alertController.c.findViewById(2131296339);
                alertController.E = textView;
                textView.setText(alertController.e);
                i2 = alertController.B;
                if (i2 != 0) {
                    alertController.D.setImageResource(i2);
                } else {
                    drawable = alertController.C;
                    if (drawable != null) {
                        alertController.D.setImageDrawable(drawable);
                    } else {
                        alertController.E.setPadding(alertController.D.getPaddingLeft(), alertController.D.getPaddingTop(), alertController.D.getPaddingRight(), alertController.D.getPaddingBottom());
                        alertController.D.setVisibility(8);
                    }
                }
            }
        }
        Object obj2 = viewGroup.getVisibility() != 8 ? 1 : null;
        i = (d == null || d.getVisibility() == 8) ? 0 : 1;
        Object obj3 = d3.getVisibility() != 8 ? 1 : null;
        if (obj3 == null) {
            findViewById3 = d2.findViewById(2131297037);
            if (findViewById3 != null) {
                findViewById3.setVisibility(0);
            }
        }
        if (i != 0) {
            nestedScrollView = alertController.A;
            if (nestedScrollView != null) {
                nestedScrollView.setClipToPadding(true);
            }
            if (alertController.f == null && alertController.g == null) {
                findViewById5 = drawable3;
            } else {
                findViewById5 = d.findViewById(2131297055);
            }
            if (findViewById5 != null) {
                findViewById5.setVisibility(0);
            }
        } else {
            findViewById5 = d2.findViewById(2131297038);
            if (findViewById5 != null) {
                findViewById5.setVisibility(0);
            }
        }
        ListView listView2 = alertController.g;
        if (listView2 instanceof RecycleListView) {
            RecycleListView recycleListView = (RecycleListView) listView2;
            Objects.requireNonNull(recycleListView);
            if (obj3 == null || i == 0) {
                recycleListView.setPadding(recycleListView.getPaddingLeft(), i != 0 ? recycleListView.getPaddingTop() : recycleListView.a, recycleListView.getPaddingRight(), obj3 != null ? recycleListView.getPaddingBottom() : recycleListView.b);
            }
        }
        if (obj2 == null) {
            findViewById5 = alertController.g;
            if (findViewById5 == null) {
                findViewById5 = alertController.A;
            }
            if (findViewById5 != null) {
                if (obj3 != null) {
                    i4 = 2;
                }
                i |= i4;
                findViewById3 = alertController.c.findViewById(2131296862);
                findViewById7 = alertController.c.findViewById(2131296861);
                int i5 = VERSION.SDK_INT;
                if (i5 >= 23) {
                    WeakHashMap weakHashMap = o.a;
                    if (i5 >= 23) {
                        findViewById5.setScrollIndicators(i, 3);
                    }
                    if (findViewById3 != null) {
                        d2.removeView(findViewById3);
                    }
                    if (findViewById7 != null) {
                        d2.removeView(findViewById7);
                    }
                } else {
                    View view2;
                    if (findViewById3 != null && (i & 1) == 0) {
                        d2.removeView(findViewById3);
                        findViewById3 = drawable3;
                    }
                    if (findViewById7 == null || (i & 2) != 0) {
                        view2 = findViewById7;
                    } else {
                        d2.removeView(findViewById7);
                        view2 = drawable3;
                    }
                    if (!(findViewById3 == null && view2 == null)) {
                        if (alertController.f != null) {
                            alertController.A.setOnScrollChangeListener(new a(alertController, findViewById3, view2));
                            alertController.A.post(new b(alertController, findViewById3, view2));
                        } else {
                            listView = alertController.g;
                            if (listView != null) {
                                listView.setOnScrollListener(new c(alertController, findViewById3, view2));
                                alertController.g.post(new d(alertController, findViewById3, view2));
                            } else {
                                if (findViewById3 != null) {
                                    d2.removeView(findViewById3);
                                }
                                if (view2 != null) {
                                    d2.removeView(view2);
                                }
                            }
                        }
                    }
                }
            }
        }
        listView = alertController.g;
        if (listView != null) {
            ListAdapter listAdapter = alertController.H;
            if (listAdapter != null) {
                listView.setAdapter(listAdapter);
                int i6 = alertController.I;
                if (i6 > -1) {
                    listView.setItemChecked(i6, true);
                    listView.setSelection(i6);
                }
            }
        }
    }

    public boolean onKeyDown(int i, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.c.A;
        Object obj = (nestedScrollView == null || !nestedScrollView.l(keyEvent)) ? null : 1;
        if (obj != null) {
            return true;
        }
        return super.onKeyDown(i, keyEvent);
    }

    public boolean onKeyUp(int i, KeyEvent keyEvent) {
        NestedScrollView nestedScrollView = this.c.A;
        Object obj = (nestedScrollView == null || !nestedScrollView.l(keyEvent)) ? null : 1;
        if (obj != null) {
            return true;
        }
        return super.onKeyUp(i, keyEvent);
    }

    public void setTitle(CharSequence charSequence) {
        super.setTitle(charSequence);
        AlertController alertController = this.c;
        alertController.e = charSequence;
        TextView textView = alertController.E;
        if (textView != null) {
            textView.setText(charSequence);
        }
    }
}
